{LCS problem}
const
  max = 1000;
type
  tt = record
         u, v : integer;
       end;
var
  x, y, z : array[1..max] of char;
  d : array[0..max, 0..max] of integer;
  trace : array[0..max, 0..max] of tt;
  m, n : integer;

procedure inp;
begin
  m := 0;
  while not eoln do
  begin
    inc(m);
    read(x[m]);
  end;
  readln;
  n := 0;
  while not eoln do
  begin
    inc(n);
    read(y[n]);
  end;
end;

procedure init;
var
  i, j : integer;
begin
  fillchar(trace, sizeof(trace), 0);
  for i := 0 to m do d[i, 0] := 0;
  for j := 0 to n do d[0, j] := 0;
end;

procedure process;
var
  i, j : integer;
begin
  for i := 1 to m do
    for j := 1 to n do
      if x[i] = y[j] then
      begin
        d[i, j] := d[i-1, j-1]+1;
        with trace[i, j] do
        begin
          u := i;
          v := j;
        end;
      end
      else
      begin
        if d[i-1, j] > d[i, j-1] then
        begin
          d[i, j] := d[i-1, j];
          with trace[i, j] do
          begin
            u := i-1;
            v := j;
          end;
        end
        else
        begin
          d[i, j] := d[i, j-1];
          with trace[i, j] do
          begin
            u := i;
            v := j-1;
          end;
        end;
      end;
end;

procedure out;
var
  i, j, t : integer;
begin
  t := 0;
  if d[m, n] = 0 then writeln('Empty')
  else
  begin
    i := m;
    j := n;
    while (i > 0) and (j > 0) do
    begin
      if x[i] = y[j] then
      begin
        inc(t);
        z[t] := x[i];
        dec(i); dec(j);
      end;
      with trace[i, j] do
      begin
        i := u;
        j := v;
      end;
    end;
  end;
  while t > 0 do
  begin
    write(z[t]);
    dec(t);
  end;
end;

begin
  inp;
  init;
  process;
  out;
end.